import './utils/utils'
import './utils/http'
App({
  token: '',
  refreshToken: '',
  // 小程序启动时
  onLaunch() {
    // 调用获取token的方法
    this.getToken()
  },
  getToken() {
    const token = wx.getStorageSync('token')
    const refreshToken = wx.getStorageSync('refreshToken')
    // this指的是小程序的实例
    this.token = token
    this.refreshToken = refreshToken
  },
  setToken(token, refreshToken) {
    token = `Bearer ${token}`
    refreshToken = `Bearer ${refreshToken}`
    wx.setStorageSync('token', token)
    wx.setStorageSync('refreshToken', refreshToken)
    // 即时更新app应用实例中的token
    this.token = token
    this.refreshToken = refreshToken
  },
})
